package com.lafeng.journey;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.lafeng.journey.bean.MovieEntity;
import com.lafeng.journey.httputils.HttpPost;

import rx.Subscriber;

public class MainActivity extends AppCompatActivity {

    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = (TextView) findViewById(R.id.text);

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                HttpPost httpPost = new HttpPost();

                httpPost.getTest(new Subscriber<MovieEntity>() {

                    @Override
                    public void onNext(MovieEntity m) {

                        textView.setText(m.toString());
                    }

                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        e.printStackTrace();
                    }
                });

            }
        });

    }
}
